<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr1 = [1,3,5,7,9]
        let arr2 = [2,4,6,8,10]
        console.log(...arr1)    //1. 展开数组
        let arr3 = [...arr1, ...arr2]   //2. 连接数组
        console.log(arr3)

        //3. 函数不定传参
        function sum(...num){
            // reduce()方法的使用
            return num.reduce((preValue, currentValue)=>{
                return preValue + currentValue
            })
        }
        console.log(sum(1,2))

        let person  = {name: "tom", age: 20}
        let person2 = {...person}   //4.  复制字面量对象，深克隆
        person.name = "jack"
        // console.log(...person)  //报错，不能展开对象
        console.log(person2)


        let person3 = {...person, name: 'Alice'}    //5. 合并对象
    </script>
</body>
</html>